<?php

/**
 * Shop filter form base class.
 *
 * @package    tsantek-shop
 * @subpackage filter
 * @author     Tomislav Šantek
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseShopFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'is_active'       => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'domain'          => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'custom_layout'   => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'show_global'     => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'pg_class_id'     => new sfWidgetFormFilterInput(),
      'pg_mch_code'     => new sfWidgetFormFilterInput(),
      'pg_signing_key'  => new sfWidgetFormFilterInput(),
      'name'            => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'company_name'    => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'description'     => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'location_id'     => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Location'), 'add_empty' => true)),
      'contact_id'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Contact'), 'add_empty' => true)),
      'pic_path'        => new sfWidgetFormFilterInput(),
      'tax'             => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'tax_included'    => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'delivery_time'   => new sfWidgetFormFilterInput(),
      'account_number'  => new sfWidgetFormFilterInput(),
      'order_id_tpl'    => new sfWidgetFormFilterInput(),
      'order_counter'   => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'invoice_id_tpl'  => new sfWidgetFormFilterInput(),
      'invoice_counter' => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'slug'            => new sfWidgetFormFilterInput(),
      'created_at'      => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'updated_at'      => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
    ));

    $this->setValidators(array(
      'is_active'       => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'domain'          => new sfValidatorPass(array('required' => false)),
      'custom_layout'   => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'show_global'     => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'pg_class_id'     => new sfValidatorPass(array('required' => false)),
      'pg_mch_code'     => new sfValidatorPass(array('required' => false)),
      'pg_signing_key'  => new sfValidatorPass(array('required' => false)),
      'name'            => new sfValidatorPass(array('required' => false)),
      'company_name'    => new sfValidatorPass(array('required' => false)),
      'description'     => new sfValidatorPass(array('required' => false)),
      'location_id'     => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Location'), 'column' => 'id')),
      'contact_id'      => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Contact'), 'column' => 'id')),
      'pic_path'        => new sfValidatorPass(array('required' => false)),
      'tax'             => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'tax_included'    => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'delivery_time'   => new sfValidatorPass(array('required' => false)),
      'account_number'  => new sfValidatorPass(array('required' => false)),
      'order_id_tpl'    => new sfValidatorPass(array('required' => false)),
      'order_counter'   => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'invoice_id_tpl'  => new sfValidatorPass(array('required' => false)),
      'invoice_counter' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'slug'            => new sfValidatorPass(array('required' => false)),
      'created_at'      => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'updated_at'      => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
    ));

    $this->widgetSchema->setNameFormat('shop_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Shop';
  }

  public function getFields()
  {
    return array(
      'id'              => 'Number',
      'is_active'       => 'Boolean',
      'domain'          => 'Text',
      'custom_layout'   => 'Boolean',
      'show_global'     => 'Boolean',
      'pg_class_id'     => 'Text',
      'pg_mch_code'     => 'Text',
      'pg_signing_key'  => 'Text',
      'name'            => 'Text',
      'company_name'    => 'Text',
      'description'     => 'Text',
      'location_id'     => 'ForeignKey',
      'contact_id'      => 'ForeignKey',
      'pic_path'        => 'Text',
      'tax'             => 'Number',
      'tax_included'    => 'Boolean',
      'delivery_time'   => 'Text',
      'account_number'  => 'Text',
      'order_id_tpl'    => 'Text',
      'order_counter'   => 'Number',
      'invoice_id_tpl'  => 'Text',
      'invoice_counter' => 'Number',
      'slug'            => 'Text',
      'created_at'      => 'Date',
      'updated_at'      => 'Date',
    );
  }
}
